-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Disallow ?
as a type name
#8735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow ?
as a type name
#8735
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the duplication in Parser here. It feels brittle. If we ever think of a new way to create types, I am sure this will slip through and they won't be checked for "?". We could do it in Typer, then it would be just one place, when we typecheck a TypeDef. Did you consider that?
Yeah the duplication isn't great, I didn't think of doing it in typer, I'll give it a go. |
7322ab1
to
d08b906
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
@@ -2321,6 +2321,13 @@ class Typer extends Namer | |||
val typer1 = localTyper(sym) | |||
typer1.typedDefDef(tree, sym)(using ctx.localContext(tree, sym).setTyper(typer1)) | |||
case tree: untpd.TypeDef => | |||
if tree.name eq tpnme.? then | |||
val addendum = if sym.owner.is(TypeParam) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move the whole case into a new method typedTypeOrCassDef
, in order to keep the dispatch code in typedUnnamed
as small as possible. That often helps the JIT to opimize.
d08b906
to
4a71417
Compare
Now that we use `?` for wildcards, we should treat it more like a keyword for types and not allow it as a type name to avoid confusion.
4a71417
to
30aa58d
Compare
Now that we use
?
for wildcards, we should treat it more like akeyword for types and not allow it as a type name to avoid
confusion.